#include "CUtiles.hpp"

CUtiles::CUtiles()
{
}

int CUtiles::str2int (const string &str)
{
	stringstream ss(str);
	int n;
	ss >> n;
	return n;
}

string CUtiles::int2str (int n)
{
	stringstream ss;
	ss << n;
	return ss.str();
}

NxVec3 CUtiles::esferaPolar(float radio,float pitch,float yaw)
{
	NxVec3 temp;
	temp.x=radio*sinf(pitch)*sinf(yaw);
	temp.y=radio*cosf(pitch);
	temp.z=radio*sinf(pitch)*cosf(yaw);
	return temp;
}

NxVec3 CUtiles::toNxVec3(Vector3 vec3)
{
	NxVec3 temp;
	temp.x = vec3.x;
	temp.y = vec3.y;
	temp.z = vec3.z;
	return temp;
}

Vector3 CUtiles::toVector3(NxVec3 vec3)
{
	Vector3 temp;
	temp.x = vec3.x;
	temp.y = vec3.y;
	temp.z = vec3.z;
	return temp;
}

NxQuat CUtiles::toNxQuat(Quaternion q)
{
	NxQuat orientacion;
	orientacion.x = q.x;
	orientacion.y = q.y;
	orientacion.z = q.z;
	orientacion.w = q.w;
	return orientacion;
}

Quaternion CUtiles::toQuaternion(NxQuat q)
{
	Quaternion orientacion;
	orientacion.x = q.x;
	orientacion.y = q.y;
	orientacion.z = q.z;
	orientacion.w = q.w;
	return orientacion;
}

Quaternion CUtiles::yawToQuaternion(float yaw)
{
	Quaternion orientacion;
	orientacion.FromAngleAxis(Degree(yaw),Vector3::UNIT_Y);
	return orientacion;
}

static float steering;
static float acceleration;
static String debugMessage;

float CUtiles::getSteering()
{
	return steering;
}

void CUtiles::setSteering(float f)
{
	steering = f;
}

float CUtiles::getAcceleration()
{
	return acceleration;
}

void CUtiles::setAcceleration(float f)
{
	acceleration = f;
}


String CUtiles::getMessage()
{
	return debugMessage;
}

void CUtiles::setMessage(String f)
{
	debugMessage = f;
}

static float physXAction;

float CUtiles::getPhysXAction()
{
	return physXAction;
}

void CUtiles::setPhysXAction(float f)
{
	physXAction = f;
}
